package org.gitos.cloud.core;

import org.gitos.cloud.cmd.interceptor.BAuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by hc on 2016/4/18 0018.
 */
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "org.gitos.cloud.background.controller")
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
	@Autowired
	BAuthInterceptor bAuthInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(bAuthInterceptor).addPathPatterns("/background/**");
	}

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/static/**").addResourceLocations("classpath:/webjars/");
		registry.addResourceHandler("/rom/**").addResourceLocations("D:/tmp");
		super.addResourceHandlers(registry);
	}
}
